﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PersonaLibrary.Data.ServiceReference;
using PersonaLibrary.PersonaliiReference;
using PersonaLibrary.View;

namespace PersonaLibrary.Commands.EditCommands
{
	internal sealed class NoteDelete : CommandBase
	{
		public override bool CanExecute(object parameter)
		{
			return parameter is int;
		}

		public override void Execute(object parameter)
		{
			DeleteView deleteView = new DeleteView();
			deleteView.ShowDialog();
			if (deleteView.DialogResult.HasValue && deleteView.DialogResult.Value)
			{
				DataServiceContextWrapper context = new DataServiceContextWrapper();
				context.CreateAndExecuteQuery<Note>(string.Format("FullDeleteNote?noteId={0}", parameter));
			}
		}
	}
}
